package chixing.day14;

public class Product implements Comparable<Product>{
    private int proId;
    private String proName;
    private float proPrice;

    public Product(){}
    public Product(int proId, String proName, float proPrice) {
        this.proId = proId;
        this.proName = proName;
        this.proPrice = proPrice;
    }

    @Override
    public int compareTo(Product anotherPro) {
        if (this.proName.compareTo(anotherPro.proName) != 0)
            return this.proName.compareTo(anotherPro.proName);
        if (this.proPrice != anotherPro.proPrice)
            return (int) (this.proPrice - anotherPro.proPrice);
        return this.proId - anotherPro.proId;
    }

    public int getProId() {
        return proId;
    }

    public void setProId(int proId) {
        this.proId = proId;
    }

    public String getProName() {
        return proName;
    }

    public void setProName(String proName) {
        this.proName = proName;
    }

    public double getProPrice() {
        return proPrice;
    }

    public void setProPrice(float proPrice) {
        this.proPrice = proPrice;
    }

    @Override
    public String toString() {
        return "Product{" +
                "proId='" + proId + '\'' +
                ", proName='" + proName + '\'' +
                ", proPrice=" + proPrice +
                '}';
    }


}
